home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* */
- /* ------------ Bit-Bucket Software <no-Inc> */
- /* \ 10001101 / Writers and Distributors of */
- /* \ 011110 / No-Cost<no-tm> Software. */
- /* \ 1011 / */
- /* ------ */
- /* */
- /* Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello */
- /* */
- /* */
- /* This module was written by Bob Hartman */
- /* */
- /* */
- /* BinkleyTerm Fidolist processing module */
- /* */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the MAKEFILE and BT.C, and also contained in the file LICENSE.210. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHORS */
- /* AT THE ADDRESSES LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO */
- /* USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE */
- /* BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU */
- /* ARE ABLE TO REACH WITH THE AUTHORS. */
- /* */
- /* */
- /* The Authors can be reached at the following addresses: */
- /* */
- /* Robert C. Hartman Vincent E. Perriello */
- /* Spark Software VEP Software */
- /* 427-3 Amherst Street 111 Carroll Street */
- /* CS2032, Suite 232 Naugatuck, CT 06770 */
- /* Nashua, NH 03061 */
- /* */
- /* FidoNet 1:132/101 FidoNet 1:141/491 */
- /* Data (603) 888-8179 Data (203) 729-7569 */
- /* */
- /* Please feel free to contact us at any time to share your comments */
- /* about our software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include <stdio.h>
- #include <sys\types.h>
- #include <sys\stat.h>
- #include <fcntl.h>
- #include <string.h>
- #include <io.h>
-
- #include "com.h"
- #include "xfer.h"
- #include "zmodem.h"
- #include "keybd.h"
- #include "sbuf.h"
- #include "sched.h"
- #include "externs.h"
- #include "prototyp.h"
-
- static int reclength = -1;
- static int nrecs = -1;
-
- void fidouser (name, zone, net, node, point)
- char *name;
- int *zone;
- int *net;
- int *node;
- int *point;
- {
- int low, high, mid, f, cond, namelen;
- char midname[80];
- char last_name_first[80];
- char *c, *p, *m;
- struct stat buffer;
-
- *zone = *net = *node = *point = -1;
-
- c = midname; /* Start of temp name buff */
- p = name; /* Point to start of name */
- m = NULL; /* Init pointer to space */
-
- while (*c = *p++) /* Go entire length of name */
- {
- if (*c == ' ') /* Look for space */
- m = c; /* Save location */
- c++;
- }
-
- if (m != NULL) /* If we have a pointer, */
- {
- *m++ = '\0'; /* Terminate the first half */
- strcpy (last_name_first, m); /* Now copy the last name */
- strcat (last_name_first, ", "); /* Insert a comma and space */
- strcat (last_name_first, midname); /* Finally copy first half */
- }
- else strcpy (last_name_first, midname); /* Use whole name otherwise */
-
- fancy_str (last_name_first); /* Get caps in where needed */
- namelen = strlen (last_name_first); /* Calc length now */
-
- midname[0] = '\0'; /* "null-terminated string" */
- strcpy (midname, net_info); /* take nodelist path */
- strcat (midname, "FIDOUSER.LST"); /* add in the file name */
- if ((f = open (midname, O_RDONLY | O_BINARY)) == -1)
- {
- reclength = -1; /* Reset all on open failure */
- return;
- }
-
- /* Find out if we have done this before */
- if (reclength == -1)
- {
- /* If not, then determine file size and record length */
-
- fstat (f, &buffer); /* Get file stats in buffer */
- read (f, midname, 80); /* Read 1 record */
- reclength = ((int) strchr (midname, '\n') - (int) midname) + 1; /* FindEnd */
- nrecs = (int) (buffer.st_size / reclength);/* Now get num of records */
- }
-
- /* Binary search algorithm */
- low = 0;
- high = nrecs - 1;
- while (low <= high)
- {
- mid = low + (high - low) / 2;
- lseek (f, (long) ((long) mid * (long) reclength), SEEK_SET);
- read (f, midname, reclength);
- if ((cond = strnicmp (last_name_first, midname, namelen)) < 0)
- high = mid - 1;
- else
- {
- if (cond > 0)
- low = mid + 1;
- else
- {
- /* Return the address information */
- close (f);
- /* The offset of 40 is just a number that should work properly */
- if (sscanf (&midname[40], "%d:%d/%d.%d", zone, net, node, point) != 4)
- {
- *zone = *net = *node = -1;
- *point = 0;
- if (sscanf (&midname[40], "%d:%d/%d", zone, net, node) != 3)
- {
- *net = *node = *point = -1;
- *zone = alias[0].Zone;
- if (sscanf (&midname[40], "%d/%d.%d", net, node, point) != 3)
- {
- *net = *node = -1;
- *zone = alias[0].Zone;
- *point = 0;
- if (sscanf (&midname[40], "%d/%d", net, node) != 2)
- {
- *zone = *net = *node = *point = -1;
- }
- }
- }
- }
- return;
- }
- }
- }
- *zone = *net = *node = *point = -1;
- close (f);
- }
-